package com.example.demo.controller;

import com.example.demo.entity.Topic;
import com.example.demo.enums.WeConFunctionType;
import com.example.demo.service.TopicService;
import com.example.demo.service.weCon.WeConService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * test 控制层
 *
 * @author jack
 * @data 2021/8/9 10:52 上午
 */
@RestController
@Api(tags = "测试控制层")
public class TestController {

  @Autowired
  private TopicService topicService;
  @Autowired
  private WeConService weConService;

  @GetMapping("hello")
  @ApiOperation(value = "向客人问好")
  public String hello() {
    return "hello springBoot!";
  }

  @GetMapping("getToken")
  @ApiOperation(value = "获取token")
  public String getToken() {
    return weConService.getToken(WeConFunctionType.CONTACTS_MANAGEMENT);
  }

  /**
   * 返点
   *
   * @param userName
   * @return
   */
  @GetMapping("topicListByUserName/{userName}")
  @ApiOperation(value = "根据用户名查询动态列表")
  public List<Topic> topicListByUserName(
      @PathVariable("userName")
          String userName) {
    return topicService.topicListByUserName(userName);
  }
}
